﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data;
using Crosland.Framework.DataHelper;
using Crosland.Framework.Base;
using Crosland.Offline.Core;
using Crosland.Offline.Data.Helper;

namespace Crosland.Offline.Data.Dao
{
    public class AlmacenDao : DaoBase
    {
        public AlmacenDao(string strConn)
            : base(strConn)
        {
        }

        AlmacenHelper helper = new AlmacenHelper();

        public List<Almacen> GetByCriteria(string centro)
        {
            List<Almacen> entitys = new List<Almacen>();
            DbCommand command = dbProvider.GetStoredProcCommand(helper.SpGetByCriteria);
            dbProvider.AddInParameter(command, helper.Lgort, DbType.String, centro);

            using (IDataReader dr = dbProvider.ExecuteReader(command))
            {
                while (dr.Read())
                {
                    entitys.Add(helper.Create(dr));
                }
            }

            return entitys;
        }
    }
}